package com.senven.payorder.controller;

import com.senven.common.entity.Branch;
import com.senven.common.vo.CommonResult;
import com.senven.payorder.service.IPayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zsy
 * @since 2022-09-05
 */
@RestController
@RequestMapping("/payorder/payorder")
public class PayOrderController {

    @Autowired
    private IPayOrderService payOrderService;

    //查询该用户的地址
    @PostMapping("/findAddressUserId")
    public CommonResult findAddressUserId( String uid){
        return payOrderService.selectUid(uid);
    }

    //逻辑删除
    @PostMapping("/deleteIsDeleted")
    public CommonResult delete(@RequestBody List<Integer> poIds){
        return payOrderService.deleteIsDeleted(poIds);
    }

    //调用order微服务的添加接口
    @PostMapping("/addOrder")
    public CommonResult addOrder(@RequestBody List<Branch> list,Integer sum,Integer paymodelid,String address,String userId){
        return payOrderService.addOrder(list,sum,paymodelid,address,userId);
    }

    //获取当前时间
    @GetMapping("/getDate")
    public CommonResult getDate(){
        return payOrderService.getData();
    }

    //计算该表中商品的总价
    @GetMapping("/sumGoods")
    public CommonResult sumGoods(String uid){
        return payOrderService.selectSum(uid);
    }

    //点击去结算后 添加商品信息到pay_order表--待支付页面
    @PostMapping("submitOrder")
    public CommonResult submitOrder(@RequestBody List<Branch> list,String uid){
        return payOrderService.adds(list,uid);
    }

    //查询商品信息
    @GetMapping("findAll")
    public CommonResult findAll(String uid){
        return payOrderService.selectAll(uid);
    }
}
